package com.candoit.webapps.pricing.listeners;

import java.io.IOException;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ValueChangeEvent;
import javax.faces.event.ValueChangeListener;

public class ChangeListenerNews implements ValueChangeListener {  
	public void processValueChange(ValueChangeEvent event)
			throws AbortProcessingException {
		 UIComponent c = (UIComponent) event.getSource();  
		 Object oldValue = event.getOldValue();
	     Object newValue = event.getNewValue();
	     FacesContext ctx = FacesContext.getCurrentInstance();
	      if (oldValue != newValue)
	        {	
	           Double cantidad = Double.valueOf((String) newValue);   
//	           ctx.getExternalContext().getInitParameter(c.getId())
	           ctx.getExternalContext().getRequestMap().remove(c.getId());
	           ctx.getExternalContext().getRequestMap().put(c.getId(), cantidad);
	           c.processUpdates(ctx);
	          
	        }        
		
	}  
}  



